$(document).ready(function(){
	$.ajax({
		type:"get",
		url:"/html/include/header.html",
		success:(data)=>{
			//$(".header").html(data);
			$(".header").append(data);
			$(".search input:first").on("keyup",function(e){
				const word = $(this).val(),
					url = `https://suggest.taobao.com/sug?code=utf-8&q=${word}&callback=?`;
				$.getJSON(url,function(data){
					let html = "";
					data.result.forEach(function(curr){
						html += `<div>${curr[0]}</div>`;
					});
					$(".search").append("<div class = 'suggest'></div>")
					$(".suggest").html(html);
				})
			});
			$(".suggest").on("click","div",function(){
				$(".search :first-child").val($(this).html());
				$(".suggest").remove();
			})
		}
	});
});
